<template>
  <div class="app-container">
    <div class="filter-container default-box">
      <span>ID：</span>
      <el-input v-model="listQuery.title" placeholder="请输入ID" style="width: 240px;" class="filter-item" />
      <span style="padding-left: 100px;">账号：</span>
      <el-input v-model="listQuery.title" placeholder="请输入账号" style="width: 240px;" class="filter-item" />
      <el-button class="filter-item" type="primary" icon="el-icon-search" style="margin-left:50px" round>
        查询
      </el-button>
      <el-button class="filter-item" icon="el-icon-refresh-right" round>
        重置
      </el-button>
    </div>
    <div class="default-box">
      <el-table
        :key="tableKey"
        v-loading="listLoading"
        :data="list"
        fit
        highlight-current-row
        style="width: 100%;"
      >
        <el-table-column label="账号" width="250">
          <template>
            <span>15820998599</span>
          </template>
        </el-table-column>
        <el-table-column label="昵称" width="250" show-overflow-toolti>
          <template>
            <span>章鱼小丸子</span>
          </template>
        </el-table-column>
        <el-table-column label="绑定小区" min-width="300" show-overflow-toolti>
          <template>
            <span>黑龙江哈尔滨道里东方友谊大厦</span>
          </template>
        </el-table-column>
        <el-table-column label="申请时间" width="250">
          <template>
            <span>2023-03-20 18:52:47</span>
          </template>
        </el-table-column>
        <el-table-column label="状态" width="250">
          <template>
            <span>
              启用
            </span>
          </template>
        </el-table-column>
        <el-table-column label="操作" min-width="250" class-name="small-padding fixed-width">
          <template>
            <el-button type="danger" @click="remarkDialog=true">禁用</el-button>
          </template>
        </el-table-column>
      </el-table>
      <pagination v-show="total>0" :total="total" :page.sync="listQuery.page" :limit.sync="listQuery.limit" @pagination="getList" />
    </div>
    <!-- 审核备注对话框 -->
    <el-dialog
      title="审核备注"
      :visible.sync="remarkDialog"
      width="30%"
      custom-class="operate-dialog"
      top="40vh"
      center
    >
      <el-form :model="oprateform" label-width="80px">
        <el-form-item label="备注">
          <el-input v-model="oprateform.remark" type="textarea" :autosize="{ minRows: 2, maxRows: 5}" placeholder="请输入审核备注" />
        </el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button @click="handleResetOperate">重置</el-button>
        <el-button type="primary" @click="handleOperate">提交</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script>
import { fetchList } from '@/api/article'
import Pagination from '@/components/Pagination' // secondary package based on el-pagination
export default {
  name: 'Adminrole',
  components: { Pagination },
  data() {
    return {
      tableKey: 0,
      list: null,
      total: 0,
      listLoading: true,
      listQuery: {
        page: 1,
        limit: 10,
        importance: undefined,
        title: undefined,
        type: undefined,
        sort: '+id'
      },
      oprateform: {
        remark: ''
      },
      remarkDialog: false // 是否展示审核备注对话框
    }
  },
  created() {
    this.getList()
  },
  methods: {
    getList() {
      this.listLoading = true
      fetchList(this.listQuery).then(response => {
        this.list = response.data.items
        this.total = response.data.total
        setTimeout(() => {
          this.listLoading = false
        }, 1.5 * 1000)
      })
    },
    // 重置审核备注
    handleResetOperate() {
      this.oprateform.remark = ''
    },
    // 审核备注提交
    handleOperate() {
      this.remarkDialog = false
    }
  }
}
</script>
<style scoped>
  [class^=el-icon-], [class*=" el-icon-"]{
    font-size: 16px;
  }
  .small-padding i{
    margin-right: 12px;
  }
  .small-padding i:last-child{
    margin-right: 0px;
  }
  ::v-deep .filter-container .el-input--medium .el-input__inner{
    width: 240px;
  }
</style>
